﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ZDSoft.LMS.Service;
using ZDSoft.LMS.Domain;
using ZDSoft.LMS.Manager;

namespace ZDSoft.LMS.Component
{
    public class DeliveryFormComponent : BaseComponent<DeliveryForm,DeliveryFormManager>, IDeliveryFormService
    {
        TransportOrderManager transportOrderManager = new TransportOrderManager();
        DriverManager driverManager = new DriverManager();
        VehicleManager vehicleManager = new VehicleManager();

        public override void Create(DeliveryForm entity)
        {
            TransportOrder order = transportOrderManager.Get(entity.TransportOrder.ID);
            order.Status = (TransportOrderStatus)((int)order.Status + 1);
            transportOrderManager.Update(order);

            entity.Transporter = driverManager.Get(entity.TransporterID);
            entity.Vehicle = vehicleManager.Get(entity.VehicleID);
            manager.Create(entity);
        }

        public override void Update(DeliveryForm entity)
        {
            entity.Transporter = driverManager.Get(entity.TransporterID);
            entity.Vehicle = vehicleManager.Get(entity.VehicleID);
            manager.Update(entity);
        }

        public IList<DeliveryForm> DemoSimpleQuery(int pageIndex, int pageSize, string transporter, string deliveryDate, string commisionder, string receiver)
        {
            return manager.DemoSimpleQuery(pageIndex, pageSize, transporter, deliveryDate,commisionder, receiver);
        }
    }
}
